/****************************************
 * 2018 - 2021 版权所有 CopyRight(c) 快程乐码信息科技有限公司所有, 未经授权，不得复制、转发
 */

package com.kclm.security03.config.security.login;

import com.kclm.security03.modules.common.dto.output.ApiResult;
import com.kclm.security03.modules.common.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/******************
 * @Author yejf
 * @Version v1.0
 * @Create 2020-07-27 22:04
 * @Description 管理认证的入口
 */
@Slf4j
@Component
public class AdminAuthenticationEntryPoint implements AuthenticationEntryPoint {

    public AdminAuthenticationEntryPoint() {
        log.debug("创建 AdminAuthenticationEntryPoint实例...");
    }

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        log.error("-- 进入commence方法：{}",authException.getMessage());
        //
        ResponseUtil.out(response, ApiResult.fail("未登录!!!"));
    }
}
